package com.example.service.impl;



import com.example.dao.UsersDao;
import com.example.entity.Users;
import com.example.service.UsersService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class UserServiceimpl implements UsersService {
    @Resource
    UsersDao usersDao;
    @Cacheable(cacheNames = "users",unless = "#result==null")
    @Override
    public PageInfo<Users> queryAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        ArrayList<Users> list = usersDao.queryAll();
        PageInfo<Users> pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public int deleteByID(Integer id) {
        return usersDao.deleteByID(id);
    }

    @Override
    public Users findById(Integer id) { return usersDao.findById(id); }

    @Override
    public int update(Users users) {
        return usersDao.update(users);
    }

    @Override
    public int insert(Users users) {
        return usersDao.insert(users);
    }
}
